package com.heima.user.controller.v1;

import com.heima.model.admin.dtos.AuthDTO;
import com.heima.model.common.constants.admin.AdminConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(value = "app用户实名认证API",tags = "app用户实名认证API")
@RestController
@RequestMapping("api/v1/auth")
public class UserController {
    @Autowired
    private UserService userService;


    /**
     * 根据状态查询需要认证相关的用户信息
     * @param dto
     * @return
     */
    @ApiOperation("根据状态查询实名认证列表")
    @PostMapping("list")
    public ResponseResult list(@RequestBody AuthDTO dto){
        return userService.loadListByStatus(dto);
    }

    @ApiOperation("实名认证通过")
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDTO DTO) {
        return userService.updateStatusById(DTO, AdminConstants.PASS_AUTH);
    }

    @ApiOperation("实名认证失败")
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDTO DTO) {
        return userService.updateStatusById(DTO, AdminConstants.FAIL_AUTH);
    }

}
